package com.tedu.mybatishomework.mapper;

import com.tedu.mybatishomework.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("INSERT INTO product(id,title,price,stock) VALUES (#{id},#{title},#{price},#{stock})")
    int insert(Product product);
    @Select("SELECT id,title,price,stock FROM product WHERE id=#{id}")
    Product findById(Integer id);
    @Delete("DELETE FROM product WHERE id=#{id}")
    int deleteById(Integer id);
    @Update("UPDATE product SET title=#{title},price=#{price},stock=#{stock} WHERE id=#{id}")
    int update(Product id);
    @Select("SELECT id,title,price,stock FROM product")
    List<Product> findAll();
}
